<script type="text/javascript">
menuLayers.show = function(id, controller, objid, objname, e) {
    var mnu = document.getElementById? document.getElementById(id): null;
    if (!mnu) return;
    this.activeMenuID = id;
    if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
    viewport.getAll();
    rewritePopupContent(controller, objid, objname);

    this.position(mnu,e);
}
</script>

<script>
function confirmAndDelete(url) {
	if (confirm("Adakah Anda Pasti?")) {
		location = url
	}
	
}


function rewritePopupContent(controller, objid, objname) {
    $('popmenu').style.width = 180;
    $('popmenu').innerHTML = "<ul>" + 
					       "<li><a href=\""  + "?act=view_sek&" + "id=" + objid + "\">&nbsp;&nbsp;Papar Maklumat Pengguna</a>" + 
					       "<li><a href=\""  + "?act=edit_sek&" + "id=" + objid + "\">&nbsp;&nbsp;Edit Maklumat Pengguna</a>" + 
					       "<li><a href=\"javascript: confirmAndDelete('?act=delete_sek&id=" + objid + "')" + "\">&nbsp;&nbsp;Hapus Rekod Pengguna</a><hr size=1>" + 
					       "<li><a href=\""  + "?act=list_kelas&" + "id=" + objid + "\">&nbsp;&nbsp;Senarai *****</a>" + 
					       "<li><a href=\""  + "?act=list_kelas&" + "id=" + objid + "\">&nbsp;&nbsp;Senarai *****</a>" + 
					       "</ul>"
     
}

function a(id) {
	MM_openBrWindow('/course_implementations/show_timetable2/'+id,'','scrollbars=yes,width=1000,height=600')
}
</script>

<script>
function getAjaxPPD() {
	//$('item_selection').innerHTML = "<font color=orange>Searching Items...please wait</font>"
	ajax_department_request("ajax.php?act=ppds_of_negeri", "negeri_id="+$("select_negeri").value)
}

function ajax_department_request(url, data) {
    var myAjax = new Ajax.Request(
        url,
        {method: 'post', parameters: data, onComplete: ajax_department_response}
    );
}

function ajax_department_response(originalRequest) {
	if (originalRequest.responseText != 0) {
		var a = originalRequest.responseText.split("$$")
		var k = new Array(a.length)
		for (i=0; i<k.length; i++) {
			k[i] = a[i].split("=")
		}
		//alert(originalRequest.responseText)
		
		str  = "<select  id=\"select_ppd\" name=\"d\" class=\"px200\" onchange=\"getAjaxSubItem()\">\n";
		str += "<option value=\"\">--Semua PPD--</option>\n"
		for (i=0; i<k.length; i++) {
			str += "<option value=\"" + k[i][1] + "\">" + k[i][0] + "</option>\n";
		}
		str += "</select>\n";
		$("select_ppd_span").innerHTML = str;
	}
	else {
		$('select_ppd_span').innerHTML = "<font color=orange>List not found</font>"
	}
}
</script>

        
        <div id="content">
            <div id="content_header" class="size_20" style=" border-bottom-width:medium; border-bottom-style:solid; border-bottom-color:#777777">
            	<img src="images/icn_mytaskTitle.gif" align="absmiddle" width="" height=""> Pengguna </div>
        	<div id="content_bgblue">
                <div id="content_bgwhite">

        	
            
<div style="border: 0pt solid silver; width: 100%;">

<? alert_some_message()?>


<form name="search" action="?act=search_pengguna" method="POST" target="" onSubmit="" onReset="">
<fieldset style="background:#ffffff; border-width:thin; border-style:solid; padding:10px; border-color:#CCCCCC;">
<legend style="font-size:1.0em; font-weight: bold;">Carian Pengguna</legend>

<table border="0" cellpadding="4" cellspacing="1" width="100%">
  <tbody>
    <tr id="SkimRow" style="display: ;">
      <td class="TableField" width="8"><font class="ErrorMessage"></font></td>
      <td class="TableField" width="150">Peringkat</td>
      <td class="TableField" width="18">:</td>
      <td class="TableRowLeft" width="487"><span class="classRow">
        <select name="n" id="select_negeri" onchange="getAjaxPPD()">
		  <option value="">--Semua Peringkat--</option>
          <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_user_level','id','user_level');
				echo $combo->printCombo2($options, "",false, $_REQUEST['n'],false,0);
			  ?>
        </select>
      </span></td>
    </tr>

    <tr id="JenisBantuanRow" style="display: ;">
      <td class="TableField" width="8">&nbsp;</td>
      <td class="TableField" width="150">Peranan</td>
      <td class="TableField" width="18">:</td>
      <td class="TableRowLeft" width="487"><span class="classRow" id="select_ppd_span">
        <select name="d" id="select_ppd">
		  <option value="">--Semua Peranan--</option>
          <?
				$combo   = new GUI();
				$options = getOptionsFromTableWithConds('ref_ppd','kod_ppd','ppd',"WHERE negeri_id=$_REQUEST[n]");
				//print_r($options);
				echo $combo->printCombo2($options, "",false, $_REQUEST['d'],false,0);
			  ?>
        </select>
      </span></td>
    </tr>
    <tr id="JenisBantuanRow" style="display: ;">
      <td class="TableField">&nbsp;</td>
      <td class="TableField">Nama Pengguna </td>
      <td class="TableField">:</td>
      <td class="TableRowLeft"><input type="text" name="q" value="<?=$_REQUEST['q']?>" size="40" /></td>
    </tr>



    <tr class="NormalTextLeft">
      <td colspan="4" align="center"><span class="TableRowLeft">
        <input name="button" type="submit" onClick="" value="Cari" style=" width:100px;">
      </span></td>
    </tr>
  </tbody>
</table>
</fieldset>

<br>
</form>

<? if ($res_count > 0) {?>
<p>

<table width="100%" border="0" cellspacing="1" cellpadding="2">
              <tr>
                <td align="left" scope="col" style=" font-weight:bold; border-bottom-style:solid; border-bottom-width:thin;">Hasil Carian  : <?=$res_count?> Rekod Dijumpai </td>
              </tr>
        </table>
			
			<br/>
            <font class="NormalTextLeft">
            
                <li>&nbsp;Isihan <i>default</i> senarai adalah pada lajur Nama.  
                </li><li>&nbsp;Klik pada lajur yang hendak diisih.
                
                        </li>
                <li>&nbsp;Klik pada Nama Institusi untuk paparan butir-butir selanjutnya.</li>
                    
            </font>
<br>
<br>
<div style=" overflow: ;">
  <table width="100%" border="0" cellspacing="1" cellpadding="2">
    <tr>
      <td>&nbsp;</td>
      <td width="20" align="left"><? if ($_REQUEST['p'] > 1) {?><a href="?act=search_sek&amp;q=<?=$_REQUEST['q']?>&p=<?=$page-1?>"><b style=" font-size:1.5em">&laquo;</b></a><? } ?></td>
      <td width="60" align="right"><select name="select2" size="0" onblur="" onchange="location='?act=search_sek&amp;q=<?=$_REQUEST['q']?>&p='+this.value" onfocus="">
          <?
for ($face=($page-5);$face<($page+5);$face++) {
	if ($face > $last_page) break;
	if ($face < 1) continue;
	$selected = '';
	if ($face == $page) {
		$selected = "selected";
	}
	else {
		$selected = "";
	}
?>
          <option value="<?=$face?>" <?=$selected?>>Muka
            <?=$face?>
            </option>
          <? } ?>
        </select>
      </td>
      <td width="20" align="right"><? if ($_REQUEST['p'] < $last_page) {?><a href="?act=search_sek&amp;q=<?=$_REQUEST['q']?>&p=<?=$page+1?>"><b style=" font-size:1.5em">&raquo;</b></a><? } ?></td>
    </tr>
  </table>
  <table width="100%" border="0" cellspacing="1" cellpadding="2" style=" border:thin; border-color:#CCCCCC; border-style:solid;">
  <tr>
    <td width="20" align="center" bgcolor="#999999" scope="col"><span class="style3">Bil</span></td>
    <td align="center" bgcolor="#999999" scope="col">Login Pengguna </td>
    <td align="center" bgcolor="#999999" scope="col">Nama Pengguna </td>
    <td align="center" bgcolor="#999999" scope="col"><span class="style3">Peranan</span></td>
    <td align="center" bgcolor="#999999" scope="col"><span class="style3">Peringkat</span></td>
    <td align="center" bgcolor="#999999" scope="col"><span class="style3">Tahap<br />
Tingkatan</span></td>
    <td align="center" bgcolor="#999999" scope="col"><span class="style3">Status</span></td>
    <td width="30" align="center" bgcolor="#999999" scope="col">&nbsp;</td>
  </tr>

<?
$even = true; 
$i = ($page-1)*20;
while ($dat = pg_fetch_object($res)) {
	$i++;
	$even = !$even;
	$bgcolor = ($even)? "":"#E9F0F5";
?>
  <tr bgcolor="<?=$bgcolor?>" onMouseOver="this.style.background='#FFFFCC'" onMouseOut="this.style.background='<?=$bgcolor?>'" onMouseDown="menuLayers.show('popmenu','index.jsp?act=', '<?=$dat->id?>', 'KPPT(PENDAKWAAN)', event)">
    <td><?=$i?>.</td>
    <td><?=strtoupper($dat->username)?></td>
    <td><?=$dat->agensi_pelaksana?></td>
    <td><?=$dat->negeri?></td>
    <td><?=$dat->ppd?></td>
    <td style=" width:150px; overflow:scroll; height:20px;"><?=$dat->alamat?></td>
    <td><? echo ($dat->aktif=='t')? "Aktif":"Tidak Aktif"; ?></td>
    <td align="center">&nbsp;</td>
  </tr>
<? } ?>
</table>
  <table width="100%" border="0" cellspacing="1" cellpadding="2">
    <tr>
      <td>&nbsp;</td>
      <td width="20" align="left"><a href="?act=list_sek&amp;p=<?=$page-1?>"><b style=" font-size:1.5em">&laquo;</b></a></td>
      <td align="right" width="60"><select name="select" size="0" onblur="" onchange="location='?act=search_sek&amp;q=<?=$_REQUEST['q']?>&amp;p='+this.value" onfocus="">
        <?
for ($face=($page-5);$face<($page+5);$face++) {
	if ($face > $last_page) break;
	if ($face < 1) continue;
	$selected = '';
	if ($face == $page) {
		$selected = "selected";
	}
	else {
		$selected = "";
	}
?>
        <option value="<?=$face?>" <?=$selected?>>Muka
          <?=$face?>
        </option>
        <? } ?>
      </select></td>
      <td width="20" align="right"><a href="?act=list_sek&amp;p=<?=$page+1?>"><b style=" font-size:1.5em">&raquo;</b></a></td>
    </tr>
  </table>
</div>

<table width="100%" border="0" cellspacing="1" cellpadding="2">
  <tr>
    <td>&nbsp;</td>
    <td width="20" align="left"><a href="?act=list_sek&p=<?=$_REQUEST['p']-1?>"></a></td>
    <td align="right" width="100">&nbsp;</td>
    <td width="20" align="right"><a href="?act=list_sek&p=<?=$_REQUEST['p']+1?>"></a></td>
  </tr>
</table>
<!--/fieldset-->
<? }
else {
	if (!empty($_REQUEST['q'])) {
		echo "Tiada hasil carian.";	
	}
}
 // end of search result list?>

</div>


 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br> <!--div id="content_footborder" style="width:930px; position:absolute; left:0; background:#ccccff; text-align:center">
  &copy; Kementerian Pelajaran Malaysia, 2010.
 </div-->
</div>
<!-- close content_bgwhite -->
</div>
<!-- close content_bgblue -->
</div>
<!-- close content -->

</div>
<!-- close container_content -->

</div>
<!-- close container -->
</body>

<!-- popup menu initial layer----->
<div id="popmenu" class="menu"></div>
<!-- EOpopup menu initial layer----->
